package com.xml_.jsoup_;

import cn.wanghaomiao.xpath.exception.XpathSyntaxErrorException;
import cn.wanghaomiao.xpath.model.JXDocument;
import cn.wanghaomiao.xpath.model.JXNode;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.File;
import java.io.IOException;
import java.util.List;

public class XpathDemo1 {
    public static void main(String[] args) throws IOException, XpathSyntaxErrorException {
        String path = "src\\com\\xml_\\student.xml";
        // 1、获取Document对象
        Document document = Jsoup.parse(new File(path), "utf-8");

        // 2、根据Document对象，创建JXDocument对象
        JXDocument jxDocument = new JXDocument(document);

        // 3、结合XPath语法查询
        // 3.1 获取所有的student标签
        List<JXNode> jxNodes = jxDocument.selN("//student");
        for (JXNode jxNode : jxNodes) {
            System.out.println(jxNode);
        }
    }
}
